Classes | Defines | Enumerations | Functions

C:/Programming/doxygen/gl2d/FBGL2D7.h File Reference

A very small and simple PC/MAC/DS rendering lib using the 3d core to render 2D stuff. More...

Go to the source code of this file.

Classes

struct  Image
 Struct for our GL-Based Images
This is our struct to hold our image attributes. You don't need to worry about this if you use the texture packer. More...

Defines

#define GL2D_RGBA(r, g, b, a)   RGBA( b, g, r, a )
 Macro to use for all the color arguments of Easy GL2D primitives.
#define GL2D_RGB(r, g, b)   RGBA( b, g, r, 255 )
 Macro to use for all the color arguments of Easy GL2D primitives.

Enumerations

enum  GL2D_FLIP_MODE { FLIP_NONE = 1 shl 0, FLIP_V = 1 shl 1, FLIP_H = 1 shl 2 }
 

Enums selecting flipping mode.

More...
enum  GL2D_BLEND_MODE {
  BLEND_TRANS = 0, BLEND_SOLID, BLEND_BLENDED, BLEND_GLOW,
  BLEND_ALPHA, BLEND_BLACK
}
 

Enums selecting Blending/Blitting mode.

More...

Functions

sub Begin2D ()
 Sets up OpenGL for 2d rendering.
Call this before drawing any of GL2D's drawing or sprite functions.
sub End2D ()
 Issue this after drawing 2d so that we don't mess the matrix stack.
The compliment of glBegin2D().
sub ScreenInit (byval as integer width, byval as integer height, byval as integer flags=0)
 Initializes GL in 2D mode.
sub ShutDown ()
 Cleans up Easy GL2D. Call this at program end. External texture management is up for the user to clean up.
sub VsynchOn ()
 Forces video card to use vertical synching. Prevents "shearing" artifacts.
function LimitFPS (byval as single max_FPS)
 Limits frames drawn per second.
Call this if your game is frame-based as opposed to time-based. RETURN - Frames per Second (single)
sub SetBlendMode (byval as GL2D_BLEND_MODE mode)
 Sets the default blending/blitting mode.
sub EnableSpriteStencil (byval as integer flag, byval as GLuint gl2dcolor, byval as GLuint gl2dcolor_env)
 Sets texture environment color Used to draw sprites in a single fill color Very useful for flash/hit animations (1 - (texture image color)) * (glColor color) + (texture image color) * (texture environment color) ie. Pure White Sprites.
sub EnableAntialias (byval as integer flag=1)
sub ClearScreen ()
 Clears the GL2D screen buffer.
sub LineGlow (byval as integer x1, byval as integer y1, byval as integer x2, byval as integer y2, byval as integer width, byval as GLuint color, byval as image ptr spr=0)
 Draws a glowing line.
sub Pset (byval as integer x, byval as integer y, byval as GLuint color)
 Draws a Pixel.
sub Line (byval as integer x1, byval as integer y1, byval as integer x2, byval as integer y2, byval as GLuint color)
 Draws a Line.
sub LineGradient (int x1, int y1, int x2, int y2, const GLuint color1, const GLuint color2)
 Draws a Line in a gradient color.
sub Box (byval as integer x1, byval as integer y1, byval as integer x2, byval as integer y2, byval as GLuint color)
 Draws a Box.
sub BoxFilled (byval as integer x1, byval as integer y1, byval as integer x2, byval as integer y2, byval as GLuint color)
 Draws a Box filled with a single color.
sub BoxFilledGradient (byval as integer x1, byval as integer y1, byval as integer x2, byval as integer y2, byval as GLuint color1, byval as GLuint color2, byval as GLuint color3, byval as GLuint color4)
 Draws a Box filled with a gradient color.
sub Triangle (byval as integer x1, byval as integer y1, byval as integer x2, byval as integer y2, byval as integer x3, byval as integer y3, byval as GLuint color)
 Draws a Triangle.
sub TriangleFilled (byval as integer x1, byval as integer y1, byval as integer x2, byval as integer y2, byval as integer x3, byval as integer y3, byval as GLuint color)
 Draws a Triangle filled with a single color.
sub TriangleFilledGradient (byval as integer x1, byval as integer y1, byval as integer x2, byval as integer y2, byval as integer x3, byval as integer y3, byval as GLuint color1, byval as GLuint color2, byval as GLuint color3)
 Draws a Triangle filled with a gradient color.
sub Ellipse (byval as integer x, byval as integer y, byval as integer a, byval as integer b, byval as integer degrees, byval as GLuint color)
 Draws a hollow Ellipse.
sub EllipseFilled (byval as integer x, byval as integer y, byval as integer a, byval as integer b, byval as integer degrees, byval as GLuint color)
 Draws a filled Ellipse.
sub Sprite (byval as integer x, byval as integer y, byval as integer flipmode, byval as Image ptr spr)
 Draws a Sprite.
sub SpriteScale (byval as integer x, byval as integer y, byval as single scale, byval as integer flipmode, byval as Image ptr spr)
 Draws a Scaled Sprite.
sub SpriteScaleXY (byval as integer x, byval as integer y, byval as single scaleX, byval as single scaleY, byval as integer flipmode, byval as Image ptr spr)
 Draws an Axis Exclusive Scaled Sprite.
sub SpriteRotate (byval as integer x, byval as integer y, byval as integer angle, byval as integer flipmode, byval as Image ptr spr)
 Draws a Center Rotated Sprite.
sub SpriteRotateScale (byval as integer x, byval as integer y, byval as integer angle, byval as single scale, byval as integer flipmode, byval as Image ptr spr)
 Draws a Center Rotated Scaled Sprite.
sub SpriteRotateScaleXY (byval as integer x, byval as integer y, byval as integer angle, byval as single scaleX, byval as single scaleY, byval as integer flipmode, byval as Image ptr spr)
 Draws a Center Rotated Axis-Exclusive Scaled Sprite.
sub SpriteOnBox (byval as integer x1, byval as integer y1, byval as integer x2, byval as integer y2, byval as single uoff, byval as single voff, byval as integer flipmode, byval as Image ptr spr)
 Draws a Stretched Sprite across a box
Useful for "Shrearing Effects".
sub SpriteOnQuad (byval as integer x1, byval as integer y1, byval as integer x2, byval as integer y2, byval as integer x3, byval as integer y3, byval as integer x4, byval as integer y4, byval as single uoff, byval as single voff, byval as integer flipmode, byval as Image ptr spr)
 Draws a Stretched Sprite across a quad
Useful for "Shrearing Effects".
sub SpriteStretchHorizontal (byval as integer x, byval as integer y, byval as integer length, byval as Image ptr spr)
 Draws a clean horizontally stretched Sprite<Br> Useful for lasers and huds.
sub SpriteStretchVertical (byval as integer x, byval as integer y, byval as integer height, byval as Image ptr spr)
 Draws a clean vertically stretched Sprite<Br> Useful for lasers and huds.
sub SpriteStretch (byval as integer x, byval as integer y, byval as integer length, byval as integer height, byval as Image ptr spr)
 Draws a clean horizontally and vertically stretched Sprite<Br> Useful for lasers, huds and dialog boxes.
sub PrintScale (byval as integer x, byval as integer y, byval as single scale, byref const as string text, byval as GLuint color)
 Prints a text.
sub overload InitSprites (Image ptr SpriteSet(), Uinteger Texcoords(), byref filename as string, byval as GLuint filtermode=GL_NEAREST)
 Initializes our spriteset with Texture Packer generated UV coordinates
Very safe and easy to use..
sub overload InitSprites (Image ptr SpriteSet(), byval as integer tile_wid, byval as integer tile_hei, byref filename as string, byval as GLuint filtermode=GL_NEAREST)
 Initializes our Tileset (like GL2D.InitSpriteset()) but without the use of Texture Packer auto-generated files.
Can only be used when tiles in a tilset are of the same dimensions.
sub DestroySprites (Image ptr Spriteset())
 Destroys/Deallocates/CleansUp our sriteset.
Call this at program end.
function LoadBmpToGLsprite (byref as string filename, byval as GLuint filtermode=GL_NEAREST)
 Loads a single power of 2 image.
RETURN - sprite Pointer of GL2D.Image.
function LoadImageToHW (byval as Image ptr spr, byval as GLuint filtermode=GL_NEAREST)
 Loads an GL2D/FB.Image to the Video hardware.
RETURN - TRUE or FALSE.
sub GetImage (byval Image ptr SpriteDest, byval as Image ptr SpriteSource, byval as integer x1, byval as integer y1, byval as integer x2, byval as integer y2)
 "Gets" a tile from a loaded spriteset.
sub FontLoad (byval as integer glyph_width, byval as integer glyph_height, byval as integer fontoffset, byref as string filename, byval as GLuint filter_mode=GL_NEAREST)
 Loads a fontset for to replace the system font
used bt PrintScale(). See fonts example for more details.

Detailed Description

A very small and simple PC/MAC/DS rendering lib using the 3d core to render 2D stuff.


Define Documentation

#define GL2D_RGB (   r,
  g,
 
)    RGBA( b, g, r, 255 )

Macro to use for all the color arguments of Easy GL2D primitives.

Parameters:
rRed channnel of the 32 bit color (0-255).
gGreen channnel of the 32 bit color (0-255).
bBlue channnel of the 32 bit color (0-255).
#define GL2D_RGBA (   r,
  g,
  b,
 
)    RGBA( b, g, r, a )

Macro to use for all the color arguments of Easy GL2D primitives.

Parameters:
rRed channnel of the 32 bit color (0-255).
gGreen channnel of the 32 bit color (0-255).
bBlue channnel of the 32 bit color (0-255).
aAlpha channnel of the 32 bit color (0-255).

Enumeration Type Documentation

Enums selecting Blending/Blitting mode.

Enumerator:
BLEND_TRANS 

Transparent blit

BLEND_SOLID 

Solid blit

BLEND_BLENDED 

Alpha Blended blit

BLEND_GLOW 

Additive Blended blit

BLEND_ALPHA 

Alpha Transparent blit

BLEND_BLACK 

Black color blit

Enums selecting flipping mode.

These enums are bits for flipping the sprites.
You can "or" GL_FLIP_V and GL_FLIP_H to flip both ways.

Enumerator:
FLIP_NONE 

No Flipping

FLIP_V 

Flip Vertical

FLIP_H 

Flip Horizontal


Function Documentation

sub Box ( byval as integer  x1,
byval as integer  y1,
byval as integer  x2,
byval as integer  y2,
byval as GLuint  color 
)

Draws a Box.

Parameters:
x1,y1Top-Left coordinate of the box.
x2,y2Bottom-Right coordinate of the box.
colorGL2D_RGBA color.
sub BoxFilled ( byval as integer  x1,
byval as integer  y1,
byval as integer  x2,
byval as integer  y2,
byval as GLuint  color 
)

Draws a Box filled with a single color.

Parameters:
x1,y1Top-Left coordinate of the box.
x2,y2Bottom-Right coordinate of the box.
colorGL2D_RGBA color.
sub BoxFilledGradient ( byval as integer  x1,
byval as integer  y1,
byval as integer  x2,
byval as integer  y2,
byval as GLuint  color1,
byval as GLuint  color2,
byval as GLuint  color3,
byval as GLuint  color4 
)

Draws a Box filled with a gradient color.

Parameters:
x1,y1Top-Left coordinate of the box.
x2,y2Bottom-Right coordinate of the box.
color1GL2D_RGBA color of the Top-Left corner.
color2GL2D_RGBA color of the Bottom-Left corner.
color3GL2D_RGBA color of the Bottom-Right corner.
color4GL2D_RGBA color of the Top-Right corner.
sub DestroySprites ( Image ptr   Spriteset() )

Destroys/Deallocates/CleansUp our sriteset.
Call this at program end.

Parameters:
SpriteSet()an array of GL2D.Image.
sub Ellipse ( byval as integer  x,
byval as integer  y,
byval as integer  a,
byval as integer  b,
byval as integer  degrees,
byval as GLuint  color 
)

Draws a hollow Ellipse.

Parameters:
x,yCenter of the ellipse.
aSemi-major axis.
bSemi-minor.
degreesAngle(in degrees).
colorGL2D_RGBA color of the ellipse.
sub EllipseFilled ( byval as integer  x,
byval as integer  y,
byval as integer  a,
byval as integer  b,
byval as integer  degrees,
byval as GLuint  color 
)

Draws a filled Ellipse.

Parameters:
x,yCenter of the ellipse.
aSemi-major axis.
bSemi-minor.
degreesAngle(in degrees).
colorGL2D_RGBA color of the ellipse.
sub EnableAntialias ( byval as integer  flag = 1 )

Enables or disables AA depending on the switch param flag(optional) TRUE = enable; FALSE(0) = disable.

sub EnableSpriteStencil ( byval as integer  flag,
byval as GLuint  gl2dcolor,
byval as GLuint  gl2dcolor_env 
)

Sets texture environment color Used to draw sprites in a single fill color Very useful for flash/hit animations (1 - (texture image color)) * (glColor color) + (texture image color) * (texture environment color) ie. Pure White Sprites.

Parameters:
gl2dcolorcolor.
gl2dcolor_envenvironment color.
flagtrue == blendmode; false(0) == modulate.
sub FontLoad ( byval as integer  glyph_width,
byval as integer  glyph_height,
byval as integer  fontoffset,
byref as string  filename,
byval as GLuint  filter_mode = GL_NEAREST 
)

Loads a fontset for to replace the system font
used bt PrintScale(). See fonts example for more details.

Parameters:
glyph_widthwidth of each character in a fontset.
glyph_heightheight of each character in a fontset.
fontoffsetcharacter offset of the fontset(normally = 32).
filenamefilename of the BMP file to load ie. "fontset.bmp".
filtermode(optional)GL_NEAREST or GL_LINEAR.
sub GetImage ( byval Image ptr  SpriteDest,
byval as Image ptr  SpriteSource,
byval as integer  x1,
byval as integer  y1,
byval as integer  x2,
byval as integer  y2 
)

"Gets" a tile from a loaded spriteset.

Parameters:
SpriteDestDestination pointer to GL2D.Image.
SpriteSourceSource pointer to GL2D.Image.
x1,y1Top-Left coordinate of the image to "get".
x2,y2Bottom-Right coordinate of the image to "get".
sub overload InitSprites ( Image ptr   SpriteSet(),
Uinteger   Texcoords(),
byref filename as  string,
byval as GLuint  filtermode = GL_NEAREST 
)

Initializes our spriteset with Texture Packer generated UV coordinates
Very safe and easy to use..

Parameters:
SpriteSet()an array of GL2D.Image.
TexCoords()Texture Packer auto-generated array of UV coords.
filenamefilename of the BMP file to load ie. "ships.bmp".
filtermode(optional)GL_NEAREST or GL_LINEAR.
sub overload InitSprites ( Image ptr   SpriteSet(),
byval as integer  tile_wid,
byval as integer  tile_hei,
byref filename as  string,
byval as GLuint  filtermode = GL_NEAREST 
)

Initializes our Tileset (like GL2D.InitSpriteset()) but without the use of Texture Packer auto-generated files.
Can only be used when tiles in a tilset are of the same dimensions.

Parameters:
SpriteSet()an array of GL2D.Image.
filenamefilename of the BMP file to load ie. "ships.bmp".
tile_widWidth of each tile in the texture.
tile_heiHeight of each tile in the texture.
filtermode(optional)GL_NEAREST or GL_LINEAR.
function LimitFPS ( byval as single  max_FPS )

Limits frames drawn per second.
Call this if your game is frame-based as opposed to time-based. RETURN - Frames per Second (single)

Parameters:
max_FPSmaximum frames to draw per second.
sub Line ( byval as integer  x1,
byval as integer  y1,
byval as integer  x2,
byval as integer  y2,
byval as GLuint  color 
)

Draws a Line.

Parameters:
x1,y1Start point of the line.
y2,y2End point of the line.
colorGL2D_RGBA color.
sub LineGlow ( byval as integer  x1,
byval as integer  y1,
byval as integer  x2,
byval as integer  y2,
byval as integer  width,
byval as GLuint  color,
byval as image ptr  spr = 0 
)

Draws a glowing line.

Parameters:
x1,y1Start point of the line.
y2,y2End point of the line.
widthThickness of the line.
colorGL2D_RGBA color.
spr(optional)an Image pointer for overriding default glow image.
sub LineGradient ( int  x1,
int  y1,
int  x2,
int  y2,
const GLuint  color1,
const GLuint  color2 
)

Draws a Line in a gradient color.

Parameters:
x1,y1Start point of the line.
y2,y2End point of the line.
color1Start point GL2D_RGBA color .
color2End point GL2D_RGBA color .
function LoadBmpToGLsprite ( byref as string  filename,
byval as GLuint  filtermode = GL_NEAREST 
)

Loads a single power of 2 image.
RETURN - sprite Pointer of GL2D.Image.

Parameters:
filenamefilename of the BMP file to load ie. "ship.bmp".
filtermode(optional)GL_NEAREST or GL_LINEAR.
function LoadImageToHW ( byval as Image ptr  spr,
byval as GLuint  filtermode = GL_NEAREST 
)

Loads an GL2D/FB.Image to the Video hardware.
RETURN - TRUE or FALSE.

Parameters:
sprpointer to GL2D/FB.Image.
filtermode(optional)GL_NEAREST or GL_LINEAR.
sub PrintScale ( byval as integer  x,
byval as integer  y,
byval as single  scale,
byref const as string  text,
byval as GLuint  color 
)

Prints a text.

Parameters:
x,yLocation of the sprite.
texttext to print.
scalescaling factor of the glyph (1 = Normal).
colorGL2D_RGBA color of the Top-Right corner.
sub Pset ( byval as integer  x,
byval as integer  y,
byval as GLuint  color 
)

Draws a Pixel.

Parameters:
xX position of the pixel.
yY position of the pixel.
colorGL2D_RGBA color.
sub ScreenInit ( byval as integer  width,
byval as integer  height,
byval as integer  flags = 0 
)

Initializes GL in 2D mode.

Parameters:
widthwidth of the window.
heightheight of the window.
flags(optional)FBGFX flags
sub SetBlendMode ( byval as GL2D_BLEND_MODE  mode )

Sets the default blending/blitting mode.

Parameters:
modeenums for blending see example files.
sub Sprite ( byval as integer  x,
byval as integer  y,
byval as integer  flipmode,
byval as Image ptr  spr 
)

Draws a Sprite.

Parameters:
xX position of the sprite.
yY position of the sprite.
flipmodemode for flipping (see GL2D_FLIP_MODE enum).
sprpointer to a Image.
sub SpriteOnBox ( byval as integer  x1,
byval as integer  y1,
byval as integer  x2,
byval as integer  y2,
byval as single  uoff,
byval as single  voff,
byval as integer  flipmode,
byval as Image ptr  spr 
)

Draws a Stretched Sprite across a box
Useful for "Shrearing Effects".

Parameters:
x1,y1First corner of the box.
x2,y2Second corner of the box.
uoff,vofftexture offsets.
flipmodemode for flipping (see GL2D_FLIP_MODE enum).
sprpointer to a GL2D.Image.
sub SpriteOnQuad ( byval as integer  x1,
byval as integer  y1,
byval as integer  x2,
byval as integer  y2,
byval as integer  x3,
byval as integer  y3,
byval as integer  x4,
byval as integer  y4,
byval as single  uoff,
byval as single  voff,
byval as integer  flipmode,
byval as Image ptr  spr 
)

Draws a Stretched Sprite across a quad
Useful for "Shrearing Effects".

Parameters:
x1,y1First corner of the quad.
x2,y2Second corner of the quad.
x3,y3Third corner of the quad.
x4,y4Fourth corner of the quad.
uoff,vofftexture offsets.
flipmodemode for flipping (see GL2D_FLIP_MODE enum).
sprpointer to a GL2D.Image.
sub SpriteRotate ( byval as integer  x,
byval as integer  y,
byval as integer  angle,
byval as integer  flipmode,
byval as Image ptr  spr 
)

Draws a Center Rotated Sprite.

Parameters:
xX position of the sprite center.
yY position of the sprite center.
angleAngle(in degrees) to rotate the sprite.
flipmodemode for flipping (see GL2D_FLIP_MODE enum).
sprpointer to a GL2D.Image.
sub SpriteRotateScale ( byval as integer  x,
byval as integer  y,
byval as integer  angle,
byval as single  scale,
byval as integer  flipmode,
byval as Image ptr  spr 
)

Draws a Center Rotated Scaled Sprite.

Parameters:
xX position of the sprite center.
yY position of the sprite center.
angleAngle(in degrees) to rotate the sprite.
scalescale value (1.0f is normal).
flipmodemode for flipping (see GL2D_FLIP_MODE enum).
sprpointer to a GL2D.Image.
sub SpriteRotateScaleXY ( byval as integer  x,
byval as integer  y,
byval as integer  angle,
byval as single  scaleX,
byval as single  scaleY,
byval as integer  flipmode,
byval as Image ptr  spr 
)

Draws a Center Rotated Axis-Exclusive Scaled Sprite.

Parameters:
xX position of the sprite center.
yY position of the sprite center.
angleAngle(in degrees) to rotate the sprite.
scaleXX-Axis scale value (1.0f is normal).
scaleYY-Axis scale value (1.0f is normal).
flipmodemode for flipping (see GL2D_FLIP_MODE enum).
sprpointer to a GL2D.Image.
sub SpriteScale ( byval as integer  x,
byval as integer  y,
byval as single  scale,
byval as integer  flipmode,
byval as Image ptr  spr 
)

Draws a Scaled Sprite.

Parameters:
xX position of the sprite.
yY position of the sprite.
scalescale value (1.0f is normal).
flipmodemode for flipping (see GL2D_FLIP_MODE enum).
sprpointer to a GL2D.Image.
sub SpriteScaleXY ( byval as integer  x,
byval as integer  y,
byval as single  scaleX,
byval as single  scaleY,
byval as integer  flipmode,
byval as Image ptr  spr 
)

Draws an Axis Exclusive Scaled Sprite.

Parameters:
xX position of the sprite.
yY position of the sprite.
scaleXX-Axis scale value (1.0f is normal).
scaleYY-Axis scale value (1.0f is normal).
flipmodemode for flipping (see GL2D_FLIP_MODE enum).
sprpointer to a GL2D.Image.
sub SpriteStretch ( byval as integer  x,
byval as integer  y,
byval as integer  length,
byval as integer  height,
byval as Image ptr  spr 
)

Draws a clean horizontally and vertically stretched Sprite<Br> Useful for lasers, huds and dialog boxes.

Parameters:
x,yLocation of the sprite.
lengthlength to stretch in pixels.
heightheight to stretch in pixels.
sprpointer to a GL2D.Image.
sub SpriteStretchHorizontal ( byval as integer  x,
byval as integer  y,
byval as integer  length,
byval as Image ptr  spr 
)

Draws a clean horizontally stretched Sprite<Br> Useful for lasers and huds.

Parameters:
x,yLocation of the sprite.
lengthlength to stretch in pixels.
sprpointer to a GL2D.Image.
sub SpriteStretchVertical ( byval as integer  x,
byval as integer  y,
byval as integer  height,
byval as Image ptr  spr 
)

Draws a clean vertically stretched Sprite<Br> Useful for lasers and huds.

Parameters:
x,yLocation of the sprite.
heightheight to stretch in pixels.
sprpointer to a GL2D.Image.
sub Triangle ( byval as integer  x1,
byval as integer  y1,
byval as integer  x2,
byval as integer  y2,
byval as integer  x3,
byval as integer  y3,
byval as GLuint  color 
)

Draws a Triangle.

Parameters:
x1,y1Vertex 1 of the triangle.
x2,y2Vertex 2 of the triangle.
x3,y3Vertex 3 of the triangle.
colorGL2D_RGBA color of the triangle.
sub TriangleFilled ( byval as integer  x1,
byval as integer  y1,
byval as integer  x2,
byval as integer  y2,
byval as integer  x3,
byval as integer  y3,
byval as GLuint  color 
)

Draws a Triangle filled with a single color.

Parameters:
x1,y1Vertex 1 of the triangle.
x2,y2Vertex 2 of the triangle.
x3,y3Vertex 3 of the triangle.
colorGL2D_RGBA color of the triangle.
sub TriangleFilledGradient ( byval as integer  x1,
byval as integer  y1,
byval as integer  x2,
byval as integer  y2,
byval as integer  x3,
byval as integer  y3,
byval as GLuint  color1,
byval as GLuint  color2,
byval as GLuint  color3 
)

Draws a Triangle filled with a gradient color.

Parameters:
x1,y1Vertex 1 of the triangle.
x2,y2Vertex 2 of the triangle.
x3,y3Vertex 3 of the triangle.
color1GL2D_RGBA color of the vertex 1.
color2GL2D_RGBA color of the vertex 2.
color3GL2D_RGBA color of the vertex 3.